<%@ page language="java" contentType="text/html; charset=UTF-8"
	pageEncoding="UTF-8"%>
<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core"%>
<!DOCTYPE HTML>
<html>
<head>
<%@include file="_header.jsp"%>
<title>添加管理员 - 管理员管理 - H-ui.admin v3.1</title>
<meta name="keywords"
	content="H-ui.admin v3.1,H-ui网站后台模版,后台模版下载,后台管理系统模版,HTML后台模版下载">
<meta name="description"
	content="H-ui.admin v3.1，是一款由国人开发的轻量级扁平化网站后台模板，完全免费开源的网站后台管理系统模版，适合中小型CMS后台系统。">
</head>
<body>
	<article class="page-container">
		<form class="form form-horizontal" enctype="multipart/form-data" id="form-admin-add">
		     <!-- 使用隐藏域传递要修改的管理员的编号 -->
		    <input type="hidden" name="id" value="${admin.id}">
			<div class="row cl">
				<label class="form-label col-xs-4 col-sm-3"><span
					class="c-red">*</span>管理员：</label>
				<div class="formControls col-xs-8 col-sm-9">
					<input type="text" class="input-text" disabled="disabled" value="${admin.account}" placeholder=""
						id="account" name="account">
				</div>
			</div>
			<div class="row cl">
				<label class="form-label col-xs-4 col-sm-3"><span
					class="c-red">*</span>新密码：</label>
				<div class="formControls col-xs-8 col-sm-9">
					<input type="password" class="input-text" autocomplete="off"
						value="" placeholder="密码为空不修改密码" id="password" name="password">
				</div>
			</div>
			<div class="row cl">
				<label class="form-label col-xs-4 col-sm-3"><span
					class="c-red">*</span>确认密码：</label>
				<div class="formControls col-xs-8 col-sm-9">
					<input type="password" class="input-text" autocomplete="off"
						placeholder="确认新密码" id="password2" name="password2">
				</div>
			</div>
			<div class="row cl">
				<label class="form-label col-xs-4 col-sm-3"><span
					class="c-red">*</span>性别：</label>
				<div class="formControls col-xs-8 col-sm-9 skin-minimal">
					<div class="radio-box">
						<input name="sex" type="radio" value="1" id="sex-1" ${admin.sex==1?"checked":"" }> <label
							for="sex-1">男</label>
					</div>
					<div class="radio-box">
						<input type="radio" id="sex-2" value="0" name="sex" ${admin.sex==0?"checked":"" }> <label
							for="sex-2">女</label>
					</div>
				</div>
			</div>
			<div class="row cl">
				<label class="form-label col-xs-4 col-sm-3">手机：</label>
				<div class="formControls col-xs-8 col-sm-9">
					<input type="text" class="input-text" value="${admin.mobile}" placeholder=""
						id="mobile" name="mobile">
				</div>
			</div>
			
			<div class="row cl">
				<label class="form-label col-xs-4 col-sm-3">邮箱：</label>
				<div class="formControls col-xs-8 col-sm-9">
					<input type="text" class="input-text" value="${admin.email }" placeholder="@" name="email"
						id="email">
				</div>
			</div>
			
			<div class="row cl">
			<label class="form-label col-xs-4 col-sm-3">附件：</label>
			<div class="formControls col-xs-8 col-sm-9"> <span class="btn-upload form-group">
				<input class="input-text upload-url" type="text" name="uploadfile" id="uploadfile" readonly nullmsg="请添加附件！" style="width:200px">
				<a href="javascript:void();" class="btn btn-primary radius upload-btn"><i class="Hui-iconfont">&#xe642;</i> 浏览文件</a>
				<input type="file" multiple name="file1" class="input-file">
				</span> </div>
		    </div>
		    
		    
			<div class="row cl">
				<label class="form-label col-xs-4 col-sm-3">地址：</label>
				<div class="formControls col-xs-8 col-sm-9">
					<input type="text" class="input-text" value="${admin.address}" name="address" id="address">
				</div>
			</div>
			
			<c:if test="${admin.role.flag!=1}">
			   <!-- 不是超级管理员才能修改角色，超级管理员不能修改角色 -->
				<div class="row cl">
					<label class="form-label col-xs-4 col-sm-3">角色：</label>
					<div class="formControls col-xs-8 col-sm-9">
						<span class="select-box" style="width: 150px;"> <select
							class="select" name="role.id" size="1">
								<c:forEach items="${roleList}" var="role">
									<option ${admin.role.id ==role.id?"selected":""  } value="${role.id }">${role.name }</option>
								</c:forEach>
						</select>
						</span>
					</div>
				</div>
			</c:if>
			
			<div class="row cl">
				<div class="col-xs-8 col-sm-9 col-xs-offset-4 col-sm-offset-3">
					<input class="btn btn-primary radius" type="submit"
						value="&nbsp;&nbsp;提交&nbsp;&nbsp;">
				</div>
			</div>
		</form>
	</article>

<%@ include file="_footer.jsp"%>

	<!--请在下方写此页面业务相关的脚本-->
	<script type="text/javascript"
		src="${pageContext.request.contextPath}/lib/jquery.validation/1.14.0/jquery.validate.js"></script>
	<script type="text/javascript"
		src="${pageContext.request.contextPath}/lib/jquery.validation/1.14.0/validate-methods.js"></script>
	<script type="text/javascript"
		src="${pageContext.request.contextPath}/lib/jquery.validation/1.14.0/messages_zh.js"></script>
	<script type="text/javascript">
	$(function() {
	    $('.skin-minimal input').iCheck({
	        checkboxClass: 'icheckbox-blue',
	        radioClass: 'iradio-blue',
	        increaseArea: '20%'
	    });

	    $("#form-admin-add").validate({
	        rules: {
	            adminName: {
	                required: true,
	                minlength: 4,
	                maxlength: 16
	            },
	            password: {
	            },
	            password2: {
	                equalTo: "#password"
	            },
	            sex: {
	                required: true,
	            },
	            'role.id': {
	                required: true,
	            },
	        },
	        onkeyup: false,
	        focusCleanup: true,
	        success: "valid",
	        submitHandler: function(form) {
	            $(form).ajaxSubmit({
	                type: 'post',
	                url: "${pageContext.request.contextPath}/sys/admin/edit",
	                success: function(data) {
	                    console.log(data);
	                    if (data.success) {
	                        //刷新父页面--刷新列表数据
	                        window.parent.location.reload();
	                        //关闭新增对话框-layer
	                        layer_close();
	                    } else {
	                        layer.msg(data.errorMsg, {
	                            icon: 1,
	                            time: 1000
	                        });
	                    }
	                },
	                error: function(XmlHttpRequest, textStatus, errorThrown) {
	                    layer.msg('error!', {
	                        icon: 1,
	                        time: 1000
	                    });
	                }
	            });
	        }
	    });
	});
	</script>
	<!--/请在上方写此页面业务相关的脚本-->
</body>
</html>